package org.phalanx.server.game;

import org.phalanx.server.PhalanxServer;
import org.phalanx.server.ServerCache.CacheManager;
import org.phalanx.server.ServerCache.Cacheable;

public class PhalanxGameRoom implements Cacheable {
	private Integer gameId;
	private boolean isPaused;
	private Integer turnLength;
	
	public PhalanxGameRoom(Integer gameId){
		setId(gameId);
	}
	
	private void setGameAttributes(){
		CacheManager cacheMgr = PhalanxServer.getServerInstance().getCacheManager();
		PhalanxGameSettings settings = (PhalanxGameSettings)cacheMgr.getElement("GameListCache", gameId);
		
		if (settings != null && settings.getTurnMode() <= PhalanxGameSettings.PURE_TIME_MODE){
			turnLength = settings.getTurnMode();
		}
	}
	
	@Override
	public Integer getId() {
		return gameId;
	}

	@Override
	public void setId(Integer id) {
		gameId = id;
		setGameAttributes();
	}

	public void setPaused(boolean isPaused) {
		this.isPaused = isPaused;
	}

	public boolean isPaused() {
		return isPaused;
	}
}
